package com.crealth.utils;

public class PhoneNumDecode {
	
	public static void main(String[] args) {
		String val = "18503058664";//~a76hqkggq8hqhh
		String result = encryptPhone(val);
		System.out.println(result);
		String rawdata = decryptPhone(result);
		System.out.println(rawdata);
	}

	public static String encryptPhone(String phoneStr) {
		if (phoneStr == null || phoneStr.length() < 4) {
			return phoneStr;
		}
		String strOperator = phoneStr.substring(0, 3);
		String strOther = phoneStr.substring(3);
		String result = strOperator + new StringBuilder(strOther).reverse().toString();
	
		return result;
	}
	
	public static String decryptPhone(String phoneStr) {
		if (phoneStr == null || phoneStr.length() < 4) {
			return phoneStr;
		}
		String strOperator = phoneStr.substring(0, 3);
		String strOther = phoneStr.substring(3);
		String result = strOperator + new StringBuilder(strOther).reverse().toString();
	
		return result;
	}
	
}
